package com.lxh.lxhcrm.model.pojos;

import org.hibernate.annotations.DynamicUpdate;

import javax.persistence.*;
import java.util.Date;
import java.util.Objects;

/**
 * 回款记录表
 * @author jw
 */
@Entity
@DynamicUpdate
@Table(name = "return_record", schema = "lxh_crm")
public class ReturnRecord {
    private int returnRecordId;
    private Date realReturnDate;
    private Double returnMoney;
    private Integer takeInvoice;
    private String remark;

    /** 合同对象 */
    private Contract contract;
    /** 回款计划 */
    private Returnmon returnmon;
    /** 付款方式对象 */
    private PaymentMethod paymentMethod;
    /** 负责人 */
    private Emp principal;

    @ManyToOne
    @JoinColumn(name = "contract_id")
    public Contract getContract() {
        return contract;
    }

    public void setContract(Contract contract) {
        this.contract = contract;
    }

    @ManyToOne
    @JoinColumn(name = "return_id")
    public Returnmon getReturnmon() {
        return returnmon;
    }

    public void setReturnmon(Returnmon returnmon) {
        this.returnmon = returnmon;
    }

    @ManyToOne
    @JoinColumn(name = "payment_method_id")
    public PaymentMethod getPaymentMethod() {
        return paymentMethod;
    }

    public void setPaymentMethod(PaymentMethod paymentMethod) {
        this.paymentMethod = paymentMethod;
    }

    @ManyToOne
    @JoinColumn(name = "principal_id")
    public Emp getPrincipal() {
        return principal;
    }

    public void setPrincipal(Emp principal) {
        this.principal = principal;
    }

    @Id
    @Column(name = "return_record_id", nullable = false)
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    public int getReturnRecordId() {
        return returnRecordId;
    }

    public void setReturnRecordId(int returnRecordId) {
        this.returnRecordId = returnRecordId;
    }


    @Basic
    @Column(name = "real_return_date", nullable = true)
    public Date getRealReturnDate() {
        return realReturnDate;
    }

    public void setRealReturnDate(Date realReturnDate) {
        this.realReturnDate = realReturnDate;
    }

    @Basic
    @Column(name = "return_mon", nullable = true, precision = 0)
    public Double getReturnMoney() {
        return returnMoney;
    }

    public void setReturnMoney(Double returnMoney) {
        this.returnMoney = returnMoney;
    }

    @Basic
    @Column(name = "take_invoice", nullable = true)
    public Integer getTakeInvoice() {
        return takeInvoice;
    }

    public void setTakeInvoice(Integer takeInvoice) {
        this.takeInvoice = takeInvoice;
    }

    @Basic
    @Column(name = "remark", nullable = true, length = 200)
    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }


    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        ReturnRecord that = (ReturnRecord) o;
        return returnRecordId == that.returnRecordId &&
                Objects.equals(realReturnDate, that.realReturnDate) &&
                Objects.equals(returnMoney, that.returnMoney) &&
                Objects.equals(takeInvoice, that.takeInvoice) &&
                Objects.equals(remark, that.remark) &&
                Objects.equals(contract, that.contract) &&
                Objects.equals(returnmon, that.returnmon) &&
                Objects.equals(paymentMethod, that.paymentMethod);
    }

    @Override
    public int hashCode() {
        return Objects.hash(returnRecordId, realReturnDate, returnMoney, takeInvoice, remark, contract, returnmon, paymentMethod);
    }

    @Override
    public String toString() {
        return "ReturnRecord{" +
                "returnRecordId=" + returnRecordId +
                ", realReturnDate=" + realReturnDate +
                ", returnMon=" + returnMoney +
                ", takeInvoice=" + takeInvoice +
                ", remark='" + remark + '\'' +
                ", contract=" + contract +
                ", returnmon=" + returnmon +
                ", paymentMethod=" + paymentMethod +
                '}';
    }
}
